#include "MyEvent.h"

MyEvent::MyEvent()
{
	time = 0;
	startTimer(1000);
	posLabel = new QLabel("position");
	QHBoxLayout *lay = new QHBoxLayout();
	lay->addWidget(posLabel);
	setLayout(lay);
	setWindowTitle("Event");
	resize(500, 500);
}
#if 1
void MyEvent::mousePressEvent(QMouseEvent *e)
{
	switch(e->button())
	{
		case Qt::LeftButton:
			posLabel->setText("Left press");
			break;
		case Qt::RightButton:
			posLabel->setText("right press");
			break;
		case Qt::MidButton:
			posLabel->setText("Middle press");
			break;
	}
}
void MyEvent::mouseMoveEvent(QMouseEvent *e)
{
	posLabel->setText(QString::number(e->x())+ "," +QString::number(e->y()));
}
void MyEvent::mouseReleaseEvent(QMouseEvent *e)
{

}
void MyEvent::keyPressEvent(QKeyEvent *e)
{
	switch(e->key())
	{
		case Qt::Key_A:
			posLabel->setText(QString::number(Qt::Key_A));
			break;
		case Qt::Key_S:
			posLabel->setText(QString::number(Qt::Key_S));
			break;
		default:
			break;
	}
}
#endif
#if 1
void MyEvent::timerEvent(QTimerEvent *e)
{
	time++;
	posLabel->setText(QString::number(time));
}
#endif
